\chapter{Composition Viewpoint}
\label{cap:CompositionViewpoint} 
\section{Physical Composition}
The whole application has been developed by using the J2EE architecture.
Thus we literally followed its standards. Then the application architecture will be divided in four tiers:
\begin{itemize}
 \item Client-tier component running on the client machine
 \item Web-tier component running on the server machine
 \item Business-tier running on the server machine
 \item Enterprise Information System (EIS the database) runninig on the EIS machine
\end{itemize}

Despite these tires, according to J2EE, we can see the the whole architecture as a three tired one: client, server and database.

\begin{figure}[htbp]
	\centering
	\includegraphics[scale = 0.4]{images/J2EE_architecture.jpg}
	\caption{J2EE architecture\label{fig:architecture}}
\end{figure}

\subsection{Client Tier}
SWIMv2 at least in the first release version (the one that will be relased for software enginering part two) will be a web application.
As a web application SWIMv2 will need a supported web browser in order to by run. All the common browser will be supported by SWIMv2.

\subsection{Server Tier}
Within the server tier we find business and web tier.

\noindent
Web components are either servlets or pages generated by using the JSP technology. Thanks to these components clients can comunicate with J2EE server: the dynamic web pages are generated in this step and sent to the clients that will visualize them.

\noindent
In the business-tier all the application logic is implemented. In this EJBeans find place. 

Business and web tiers are connected to each other so the requests of the clients can find place. In particular business tier will have a direct access to the database-tier.

\subsection{Database Tier}
This layer will simply implement the database and its logic.


\section{Logical Composition}

From a logical-functional level, the entire system can be decompose in four macro components. Application web subsystem, business-logic subsystem, data-persistent subsystem and the database that actually keep the data persistency by storing data on the physical disc.

\begin{figure}[htbp]
	\centering 
	\includegraphics[scale = 0.32, angle = 90]{images/component_diagram.pdf}
	\caption{UML Component Diagram of the system \label{fig:components}}
\end{figure}
\newpage
\subsection{Persistence Component}
A component that is involved in maintaining the persistency is the one that interfaces with the database. This component will recover data and will make the data changes to be persistent. Database interaction is grant by the JDBC connector. Since we use J2EE technology to develope the project and JBoss as application server, Hybernate, together with the Enterprise Java Beans (EJB) does the kind of things described above.
Precisely, Hybernate is an open source middleware used to develop java application which gives an Object-relational mapping (ORM).


\subsection{Business Logic}
Business logic is the subsystem that interfaces client with the data in a way such that only operation allowed by the system can be done, a consistent status of the application is kept and unauthorized access are prevented.
Many modules compose the business logic, some correlated to each other and other independent. This modules interface with the client in order to grant all the valid operation request by the system users.
These modules are the follows:

\begin{description}
	\item[Autentication]: Contains the logic necessary to verify authentication of user and admins.
	\item[Captcha Engine]: Contains the logic that generates and verifies numeric/textual captcha.
	\item[Friends Engine]: Contains the logic that handles friends requests and suggestions.
	\item[Mailbox]: Contains the logic that handles the reception, the dispatch and the consultation of the private mail box.
	\item[Search Engine]: Component that interprets users' requests and gives their research a result.
	\item[Registration]: Component that handle the registration for the web site and verify a correct registration by mail.
	\item[Amministration]: Contains the logic that handles with the user ban and other administrative tools regarding the site supervision.
	\item[Ability Manager]: Contains the logic necessary to send an ability request o the admins and to handle its acceptance.
	\item[Help Request Engine]: Component that handles with help requests form they performing to the feedback release.
	\item[Personal Data Manager]:Component that contains all the logic to handle with personal data.
\end{description}

\subsection{Web Application}

The web application is substantially divided into three macro component:
\begin{description}
 \item[Site Basics]: contains all the functionalities that are always available for each users, registered or guest ones.
 \item[Personal Site]: contains all the functionalities dedicated to the registered users.
 \item[Site Amministration]: contains all the advanced functionalities related to the users handling and to their requests approvation.
\end{description}
As shown in the component diagram, Site Basic functionalities are used by both the components, while the Personal Site ones are needed even for the administrative phase.

